<?php


namespace App\Models\MaintainRepair;

use App\Models\Model;
use Illuminate\Database\Eloquent\SoftDeletes;

class MrCost extends Model
{
    use SoftDeletes;

    protected $table = 'akbus_mr_cost';

    protected $fillable = [
        'mr_apply_id',
        'number',
        'content',
        'type',
        'amount',
    ];

    /**
     * 不可批量赋值的属性。
     *
     * @var array
     */
    protected $guarded = [
    ];

    /**
     * 类型转化
     *
     * @var array
     */
    protected $casts = [
    ];

    /**
     * 隐藏的字段
     *
     * @var array
     */
    protected $hidden = [
    ];

    /**
     * 拼接车牌号字符
     *
     * @param  string  $value
     *
     * @return string
     */
    public function getLicensePlateNumAttribute($value)
    {
        return '陕G'.$value;
    }

    /**
     * 费用文件
     *
     * @return \Illuminate\Database\Eloquent\Relations\HasMany
     */
    public function costFile()
    {
        return $this->hasmany('App\Models\MaintainRepair\MrCostFile', 'mr_cost_id');
    }

    /**
     * 费用明细
     *
     * @return \Illuminate\Database\Eloquent\Relations\HasMany
     */
    public function detail()
    {
        return $this->hasmany('App\Models\MaintainRepair\MrCostFile', 'mr_cost_id');
    }
}
